package gold.digger;

import gold.utils.InputUtil;

import java.util.*;

/**
 * Created by fanzhenyu02 on 2021/12/10.
 * common problem solver template.
 */
public class LC1078 {
    public long startExecuteTime = System.currentTimeMillis();


    class Solution {
        public String[] findOcurrences(String text, String first, String second) {
            final String[] split = text.split(" ");
            List<String> res = new ArrayList<>();

            for (int i = 0; i < split.length - 2; i++) {
                if (first.equals(split[i]) && second.equals(split[i + 1])) res.add(split[i + 2]);
            }

            return res.toArray(new String[res.size()]);
        }
    }


    public void run() {
        Solution solution = new Solution();
        int[] arr = InputUtil.toIntegerArray("[1,2,3]");
        System.out.println(Arrays.toString(solution.findOcurrences("alice is a good girl she is a good student", "a", "good")));
        System.out.println(Arrays.toString(solution.findOcurrences("we will we will rock you", "we", "will")));
    }

    public static void main(String[] args) throws Exception {
        LC1078 an = new LC1078();
        an.run();

        System.out.println("\ncurrent solution total execute time: " + (System.currentTimeMillis() - an.startExecuteTime) + " ms.");
    }
}
